package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type ViperDataStruct struct {
	Mysql
	Redis
	Alipay
}
type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type Redis struct {
	Addr     string
	Password string
	DB       int
}
type Alipay struct {
	PrivateKey string
	AppId      string
	NotifyURL  string
	ReturnURL  string
}

var Data ViperDataStruct

func ViperDataFs() {
	viper.SetConfigFile("appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	} else {
		fmt.Println("文件转读取成功")
	}
	err = viper.Unmarshal(&Data)
	if err != nil {
		panic(err)
	} else {
		fmt.Println("文件转json成功")
	}
	fmt.Println(Data)

}
